package com.yidu.logisticssystem.service.impl;

import com.yidu.logisticssystem.entity.LogisticsCharge;
import com.yidu.logisticssystem.dao.LogisticsChargeDao;
import com.yidu.logisticssystem.service.LogisticsChargeService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 运费计价标准(LogisticsCharge)表服务实现类
 *
 * @author makejava
 * @since 2021-03-15 13:59:53
 */
@Service("logisticsChargeService")
public class LogisticsChargeServiceImpl implements LogisticsChargeService {
    @Resource
    private LogisticsChargeDao logisticsChargeDao;

    /**
     * 根据地区id查询收费标准
     * @param logisticsCharge
     * @return 实例化对象
     */
    @Override
    public LogisticsCharge queryByMapId(LogisticsCharge logisticsCharge) {
        return logisticsChargeDao.queryByMapId(logisticsCharge);
    }

    /**
     * 通过ID查询单条数据
     *
     * @param chargeId 主键
     * @return 实例对象
     */
    @Override
    public LogisticsCharge queryById(Integer chargeId) {
        return this.logisticsChargeDao.queryById(chargeId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<LogisticsCharge> queryAllByLimit(int offset, int limit) {
        return this.logisticsChargeDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param logisticsCharge 实例对象
     * @return 实例对象
     */
    @Override
    public LogisticsCharge insert(LogisticsCharge logisticsCharge) {
        this.logisticsChargeDao.insert(logisticsCharge);
        return logisticsCharge;
    }

    /**
     * 修改数据
     *
     * @param logisticsCharge 实例对象
     * @return 实例对象
     */
    @Override
    public LogisticsCharge update(LogisticsCharge logisticsCharge) {
        this.logisticsChargeDao.update(logisticsCharge);
        return this.queryById(logisticsCharge.getChargeId());
    }

    /**
     * 通过主键删除数据
     *
     * @param chargeId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer chargeId) {
        return this.logisticsChargeDao.deleteById(chargeId) > 0;
    }
}
